import React from 'react'
import { HashRouter, Routes, Route, Navigate } from 'react-router-dom'
import Login from '../views/Login'
import Index from '../Layout'
import { getToken, setToken, removeToken } from '../utils/auth'

const IsLogin = () => {
  let token = getToken()
  console.log(token, '==========');
  if (!token) {
    return <Navigate to='/login' />
  } else {
    console.log('已经登录')
    return <Index>已经登录</Index>
  }
}  

const Router = () => {
  
  return (
    <>
      <HashRouter>
        <Routes>
        <Route
            path="/"
            element={<IsLogin />}
          />
          <Route
            path='/login'
            element={<Login />}
          />
        </Routes>
      </HashRouter>
    </>
  )
}

export default Router;